package com.kainitram.drivebook.fragments;

import android.app.Activity;

import com.kainitram.drivebook.DriveBookMainActivity;
import com.kainitram.drivebook.data.DatabaseHelper;
import com.kainitram.library.BaseListFragment;
import com.kainitram.library.sm.BaseSlidingFragmentActivity;
import com.kainitram.library.sm.SlidingContentFragment;
import com.kainitram.morm.Model;

/**
 * Abstract base class for drive book list fragments
 * 
 * @author Mino
 * 
 */
public abstract class BaseDBListFragment<T extends Model> extends
		BaseListFragment<T> implements SlidingContentFragment {

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);

		BaseSlidingFragmentActivity act = (BaseSlidingFragmentActivity) activity;
		act.setTitle(String.format("%s - %s", act.getApplicationTitle(),
				this.getFragmentTitle()));
	}

	@Override
	public int getViewID() {
		return 0;
	}

	/**
	 * Get database helpers
	 * 
	 * @return database helper
	 */
	public DatabaseHelper getDatabaseHelper() {
		return ((DriveBookMainActivity) getActivity()).getDatabaseHelper();
	}
}
